#
# BreakerWinChain.py
#
# Author: Elysia Haight
#
# $Id: BreakerWinChain.py 324 2008-10-17 02:18:09Z malerba89 $

from WinChain import *
from Popup import *

#This class checks whether or not the breaker has won the game.
class BreakerWinChain(WinChain):

        
        
#Constructor
        def __init__(self):
                self.NO_WIN = 0
                self.BREAKER_WIN = 1
                self.MAKER_WIN = 2
                self.BLACK = 2

# Check for breaker win condition. Return breaker win condition if it is found. Otherwise,
# continue to next condition.
        def handle_request(self, move_stack) :
                all_black = False
                if len(move_stack) > 0 and move_stack[len(move_stack)-1].get_player() == 'Maker':
                        all_black = True
                if (len(move_stack) > 0):
                        for piece in move_stack[len(move_stack)-1].get_pieces():
                                if piece != self.BLACK:
                                        all_black = False
                                        break
                        if all_black:
                                self.popup = Popup()
                                self.popup.win_game_popup(self.BREAKER_WIN)
                                return self.BREAKER_WIN
                        else :
                                return self.NO_WIN
		else:
                        return self.NO_WIN
